package cn.edu.lingnan.web;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.edu.lingnan.dao.registDao;
import cn.edu.lingnan.model.User;

public class RegisterServlet extends HttpServlet {

	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		System.out.println("11111111111111111111");
		String id=req.getParameter("Id");
		String username=req.getParameter("username");
		String password=req.getParameter("password1");
		String ssuper=req.getParameter("ssuper");
		System.out.println(id);
        User s= new User();
		s.setId(id);
		s.setUserName(username);
		s.setPassword(password);
		s.setSspur(ssuper);
		registDao sd=new registDao();
		int flag = 0;
		try {
			flag = sd.insertInfoToUser(s);
		} catch (ClassNotFoundException e) {
			
			e.printStackTrace();
		}
		if(flag==2)
			resp.sendRedirect(req.getContextPath()+"/index.html");
		else
			resp.sendRedirect(req.getContextPath()+"/register.html");
	}
}
